// 引入axios（axios进行了二次封装）
import request from '@/utils/request'

//获取文章归档列表
export function getArchiveList(current, size){
  return request({
    url:'/archives/list',
    method:'get',
    params: {
      current:current,
      size:size,
    }
  })
}

//获取首页文章
export function getHomeArticleList(){
  return request({
    url:'/article/list',
    method:'get',
  })
}

//获取热门文章列表
export function getHotArticleList(){
  return request({
    url:'/article/hot',
    method:'get'
  })
}

//获取每天的文章数量
export function getArticleCountDate(year){
  return request({
    url:'/article/countDate',
    method:'get',
    params:{
      year:year
    }
  })
}


//获取编辑文章信息 /admin/article/edit/{articleId}
export function getEditArticleInfo(articleId) {
  return request({
    url: `/admin/article/edit/${articleId}`,
    method: 'get',
  })
}

//查看最新评论 /recent/comment
export function getRecentCommentList() {
  return request({
    url: `/recent/comment`,
    method: 'get',
  })
}

//查看文章详情 /article/{articleId}
export function getArticleDetail(articleId) {
  return request({
    url: `/article/${articleId}`,
    method: 'get',
  })
}

//获取评论列表
export function getCommentList(commentType,typeId,current,size){
  return request({
    url:'/comment/list',
    method:'get',
    params:{
      commentType,
      current,
      typeId,
      size
    }
  })
}

//添加文章评论
export function addComment(data) {
  return request({
    url: '/comment/add',
    method: 'post',
    data: data, // 直接传递 commentDTO 对象
  });
}


//最新文章评论 /recent/{articleId}/comment

export function getRecentComment(articleId) {
  return request({
    url: `/recent/${articleId}/comment`,
    method: 'get',
  })
}